package com.example.tutormanagement.controller;

import com.example.tutormanagement.pojo.Result;
import com.example.tutormanagement.pojo.Salary;
import com.example.tutormanagement.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * &#064;Date: 23/06/15-14:25
 * &#064;Description:as same as charge table
 */
@RestController
@RequestMapping("/salary")
public class SalaryController {

    @Autowired
    private SalaryService salaryService;

    // get-all-data
    @GetMapping
    public Result list() {
        List<Salary> salaries = salaryService.list();
        return Result.success(salaries);
    }

    @GetMapping("/{id}")
    public Result select(@PathVariable String id) {
        Salary salary = salaryService.select(id);
        return Result.success(salary);
    }

    // new-data
    @PostMapping
    public Result insert(@RequestBody Salary salary) {
        salaryService.insert(salary);
        return Result.success();
    }

    // update-data
    @PutMapping("/{id}")
    public Result update(@RequestBody Salary salary, @PathVariable String id) {
        salaryService.update(salary, id);
        return Result.success();
    }
}
